package org.example;

import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

/**
 * @program: itcast-MyRPC
 * @description:
 * @author: zhanghz001
 * @create: 2021-02-19 14:27
 **/
public class SocketClient {
    public static void main(String[] args) throws IOException, InterruptedException {
        //创建socket链接
        Socket socket = new Socket("127.0.0.1", 65534);
        //输出数据
        // TimeUnit.SECONDS.sleep(60);
        System.out.println("客户端发送消息");
        //1、客户端已经连接服务端，尚未发送数据，read阻塞
        // 2、新的客户端无法正常连接
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        socket.getOutputStream().write(str.getBytes());
        //关闭socket1 
        socket.close();
    }
}
